##################################################################################################################################
#
# Copyright (C) 2008-2013 Mind System Connection. Lda. Part of Daidze Software, created by Siqsuruq. All other rights reserved.
#
# Mind System Connection Webpage: www.msysc.org
# Daidze Software Page: www.daidze.com www.daidze.org
# E-mail: admin@msysc.org, siqsuruq@gmail.com
#
##################################################################################################################################

proc tbllist_to_exel {table_var name} {
	set tbllist [dict get [$::daidze_main get_fdata] $table_var]

	set appId [::Excel::OpenNew]
	set workbookId [::Excel::AddWorkbook $appId]
	set xlsFile [file join [pwd] $::export_dir [::msgcat::mc "$name"]] 
	append xlsFile [::Excel::GetExtString $appId]

	file delete -force $xlsFile
	set useHeader true
	
    set ::Excel::useTwapiForClipboard true

    set worksheetId [::Excel::AddWorksheet $workbookId [::msgcat::mc "$name"]]
    set cellsId [::Excel::GetCellsId $worksheetId]

    ::Excel::TablelistToWorksheet $tbllist $worksheetId $useHeader


update
::Excel::SaveAs $workbookId $xlsFile
::Cawt::Destroy
}